<template>
  <div>
    <!-- 顶部 -->
    <van-nav-bar
      title="歌单详情"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <!-- 具体显示 -->
    <!-- <div class="details-BK"></div> -->
    <div
      class="details-BK-Box bk"
      :style="`background-image: url(${songDetails.coverImgUrl}?param=170y170)`"
    ></div>
    <div class="detailsBox">
      <div class="detailsImg">
        <img :src="songDetails.coverImgUrl" />
      </div>
      <div class="detailsRight">
        <h3>{{ songDetails.name }}</h3>
        <div class="singerAvar">
          <img :src="songDetails.creator.avatarUrl" />
        </div>
        <div class="singerName">{{ songDetails.creator.nickname }}</div>
      </div>
    </div>

    <!-- 歌单列表 -->
    <ul class="newestList">
      <li v-for="(item, index) in tracks" :key="index" @click="goPlay(item.id)">
        <div class="newestLeft">
          <div class="spanTitleBox">
            <span class="spanTitle">{{index+1}}&nbsp;{{ item.name }}</span>
          </div>
          <span class="spanAuthor">隔壁老范</span>
          <!-- <span v-for="(item, index) in tracks" :key="index">{{ item.song.artists }} - {{ item.song.album.name }}</span> -->
        </div>
        <div class="newestRight">
          <van-icon name="play-circle-o" size="28" color="#999" />
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import { getSongListDetails } from "../api/api";
import { Toast } from "vant";

export default {
  name: "songDetails",
  created() {
    getSongListDetails(this.$route.query.id).then((res) => {
      console.log(res);
      if (res.code == 200) {
        this.songDetails = res.playlist;
        this.tracks = res.playlist.tracks;
      }
    });
    
  },
  data() {
    return {
      songDetails: "",
      tracks: "",
    };
  },
  methods: {
    // 处理作者
    singer(arr) {
      let singerName = [];
      arr.forEach((item) => {
        singerName.push(item.name);
      });
      return singerName.join(" / ");
    },
    onClickLeft() {
      window.history.go(-1);
    },
    onClickRight() {
      Toast("按钮");
    },
     // 去音乐播放
    goPlay(id){
        this.$router.push({path:"/mp3", query: {id}});
      },
  },
};
</script>
<style scoped lang="less">
* {
  margin: 0;
  padding: 0;
}
.details-BK-Box {
  float: left;
  content: "";
  width: 100%;
  height: 186px;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden !important;
  padding: 30px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.bk {
  position: absolute;
  overflow: hidden;
  background-size: cover;
  filter: blur(20px);
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  content: "";
}
.detailsBox {
  float: left;
  position: relative;
  top: 34px;
  left: 3.5%;
  width: 93%;
  height: 68%;
  //   background-color: aquamarine;
}
.detailsImg {
  float: left;
  width: 130px;
  height: 100%;
  //   background-color: red;
}
.detailsImg > img {
  width: 100%;
  height: 100%;
}
.detailsRight {
  float: right;
  margin-left: 10px;
  width: 58%;
  height: 100%;
  //   background-color: #999;
}
.detailsRight > h3 {
  font-weight: 500;
  color: #fff;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.singerAvar {
  float: left;
  margin-top: 12%;
  width: 30px;
  height: 30px;
  //   background-color: red;
}
.singerAvar > img {
  width: 100%;
  height: 100%;
  border-radius: 15px;
}
.singerName {
  position: absolute;
  height: 30px;
  width: 56%;
  float: right;
  top: 56%;
  left: 53%;
  line-height: 30px;
  color: #fff;
  //   background-color: red;
}
// 歌单列表
.newestList {
  width: 100%;
  margin: auto;
  //   overflow: hidden;
  margin-top: 196px;
  background-color: #fff;
  position: absolute;
}
.newestList > li {
  margin: auto;
  overflow: hidden;
  position: relative;
  width: 94%;
  height: 42px;
  // line-height: 60px;
  border-bottom: 1px solid #ddd;
  padding: 6px 1px;
  //   background-color: #fff;
}

.footerBox {
  width: 100%;
  height: 200px;
}
.spanTitle {
  font-size: 18px;
//   white-space: nowrap;
//   overflow: hidden;
//   text-overflow: ellipsis;
}
.spanTitleBox {
  width: 300px;
//   background-color: red;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spanAuthor {
  display: block;
  font-size: 12px;
  color: #999;
}
.newestLeft {
  float: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.newestLeft > span > :first-child {
  font-size: 28px;
  color: red;
}
.newestRight {
  float: right;
  position: absolute;
  top: 28%;
  right: 5px;
  width: 28px;
  height: 28px;
  // background-color: aqua;
}
</style>
